#define DEBUG
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

int nlimit, mlimit, klimit, ylimit;

void generate_data() {
  srandom(time(NULL));
  FILE *f = fopen("game.in", "w");
  int n=random()%nlimit+1, m=random()%mlimit+1, k=random()%klimit+1;
  fprintf(f, "%d %d %d\n", n, m, k);
  for (int i=1; i<=k; i++) {
    if (random()%2) {
      fprintf(f, "R %ld %ld\n", random()%n+1, random()%ylimit);
    } else {
      fprintf(f, "S %ld %ld\n", random()%m+1, random()%ylimit);
    }
  }
  fclose(f);
}

int main() {
  int times;
  printf("n, m, k, y, times:");
  scanf("%d %d %d %d %d", &nlimit, &mlimit, &klimit, &ylimit, &times);

  for (int i=1; i<=times; i++) {
    generate_data();
    system("./0");
    system("./0_bf");
    if (system("cmp game.out game_bf.out")) {
      printf("Error!");
      return -1;
    }
  }

  return 0;
}
